<%--
  Created by IntelliJ IDEA.
  User: 花生
  Date: 2020/5/17
  Time: 22:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<script>
    var navId=localStorage.getItem("navId");//得到id
    $(function () {
        chaxunById();
    });
    function chaxunById() {
        $.ajax({
            url:'/NavFindById',
            data:{id:navId},
            type:'get',
            dataType:'json',
            success: function (data) {
                $("#id").val(data[0].id);
                $("#href").val(data[0].href);
                $("#title").val(data[0].title);
                var status=data[0].status;
                if (status==1){
                    $("input[name='status'][value=启用]").attr("checked",true);
                }else {
                    $("input[name='status'][value=停用]").attr("checked",true);
                }
            }
        })
    }
    function tijiao() {
        var status=$("input[name='status']:checked").val();
    status= status == "启用" ? 1 : 0;
        var data={id:$("#id").val(),
            href:$("#href").val(),
            title:$("#title").val(),
            status: status,
        }
        $.ajax({
            url:'/NavUpdate',
            data:data,
            type:'post',
            dataType:'json',
            success: function () {
                if (data==1){
                    $('#homeRight').load('/back/nav/NavSelect.jsp');
                }else {
                    alert("操作失败");
                }
            }
        })

    }
</script>
<body>
<div>
    <input type="text" id="id" readonly>
</div>
<div>
    导航链接<input type="text" name="href" id="href">
</div>
<div>
    导航标题<input type="text" name="title" id="title">
</div>
<div>状态：<label><input type="radio" name="status" value="启用"> 启用</label>
<label><input type="radio" name="status" value="停用">停用</label>
</div>
<div>
    <input type="button" value="修改" onclick="tijiao()">
</div>
</body>
</html>
